接續 上一篇 ZFS 的實作。
如果動作夠快,
可在zpool status看到所掛載的新硬碟正在鏡射的進度。
# zpool status trout
pool: trout
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress, 69.10% done, 0h0m to go
config:
NAME STATE READ WRITE CKSUM
trout ONLINE 0 0 0
mirror ONLINE 0 0 0
/home/ocean/disk2 ONLINE 0 0 0
/home/ocean/disk1 ONLINE 0 0 0
errors: No known data errors
只要鏡射完成,
pool就又回到正常狀態。
(也可用ls來檢查檔案仍在該處)
# zpool status trout
pool: trout
state: ONLINE
scrub: resilver completed with 0 errors on Wed Mar 7 20:58:17 2007
config:
NAME STATE READ WRITE CKSUM
trout ONLINE 0 0 0
mirror ONLINE 0 0 0
/home/ocean/disk2 ONLINE 0 0 0
/home/ocean/disk1 ONLINE 0 0 0
errors: No known data errors
增加到鏡射Pool
可以在不離線的情況下,
加磁碟到pool裡;
現在把trout這pool增加一倍:
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
trout 123M 64.5M 58.5M 52% ONLINE -
# zpool add trout mirror /home/ocean/disk3 /home/ocean/disk4
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
trout 246M 64.5M 181M 26% ONLINE -
動作立即生效,
在pool裡的檔案系統保持著可用的狀態,
從狀態可看到在pool中包含兩個鏡射:
# zpool status trout
pool: trout
state: ONLINE
scrub: resilver completed with 0 errors on Wed Mar 7 20:58:17 2007
config:
NAME STATE READ WRITE CKSUM
trout ONLINE 0 0 0
mirror ONLINE 0 0 0
/home/ocean/disk2 ONLINE 0 0 0
/home/ocean/disk1 ONLINE 0 0 0
mirror ONLINE 0 0 0
/home/ocean/disk3 ONLINE 0 0 0
/home/ocean/disk4 ONLINE 0 0 0
errors: No known data errors
執行 zool iostate -v 可看看檔案是被寫到pool裡的什麼地方,
zpool iostat -v trout
capacity operations bandwidth
pool used avail read write read write
---------------------------- ----- ----- ----- ----- ----- -----
trout 64.5M 181M 0 0 13.7K 278
mirror 64.5M 58.5M 0 0 19.4K 394
/home/ocean/disk2 - - 0 0 20.6K 15.4K
/home/ocean/disk1 - - 0 0 0 20.4K
mirror 0 123M 0 0 0 0
/home/ocean/disk3 - - 0 0 0 768
/home/ocean/disk4 - - 0 0 0 768
---------------------------- ----- ----- ----- ----- ----- -----
所有資料被寫到第一個鏡射,
而沒有被寫到第二個鏡射。
這樣是合理的,
因為第二個鏡射中的兩個磁碟,
是在資料寫入後才增加的。
如果寫些新資料到pool裡,
就會用到新的鏡射:
# mkfile 64m /trout/quuxx
# zpool iostat -v trout
capacity operations bandwidth
pool used avail read write read write
---------------------------- ----- ----- ----- ----- ----- -----
trout 128M 118M 0 0 13.1K 13.6K
mirror 95.1M 27.9M 0 0 18.3K 9.29K
/home/ocean/disk2 - - 0 0 19.8K 21.2K
/home/ocean/disk1 - - 0 0 0 28.2K
mirror 33.2M 89.8M 0 0 0 10.4K
/home/ocean/disk3 - - 0 0 0 11.1K
/home/ocean/disk4 - - 0 0 0 11.1K
---------------------------- ----- ----- ----- ----- ----- -----
留意一下與之前的狀況比較,
有一些資料已寫到新的鏡射中,
ZFS會把pool裡的資源做最佳的利用。
這是第一部份,
在第二部份將會看到管理ZFS檔案系統,
及在pool中產生多個檔案系統。
若想知道更多ZFS背後的原理或找一些參考資料,
可參閱:
ZFS Administration Guide
OpenSolaris ZFS
ZFS BigAdmin
ZFS Best Practices
本文簡譯自 zfs tutorial part 1